package com.ruoyi.backend.controller;

import com.ruoyi.backend.domain.SysUserRealAuth;
import com.ruoyi.backend.service.ISysUserRealAuthService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 实名认证Controller
 * 
 * @author wjr
 * @date 2025-09-23
 */
@RestController
@RequestMapping("/backend/real_auth")
@Api(tags = "实名认证")
public class SysUserRealAuthController extends BaseController
{
    @Autowired
    private ISysUserRealAuthService sysUserRealAuthService;

    /**
     * 查询实名认证列表
     */
    @PreAuthorize("@ss.hasPermi('backend:real_auth:list')")
    @GetMapping("/list")
    @ApiOperation("查询实名认证列表")
    public TableDataInfo list(SysUserRealAuth sysUserRealAuth)
    {
        startPage();
        List<SysUserRealAuth> list = sysUserRealAuthService.selectSysUserRealAuthList(sysUserRealAuth);
        return getDataTable(list);
    }

    /**
     * 获取实名认证详细信息
     */
    @PreAuthorize("@ss.hasPermi('backend:real_auth:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取实名认证详细信息")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(sysUserRealAuthService.selectSysUserRealAuthById(id));
    }

    /**
     * 新增实名认证
     */
    @PreAuthorize("@ss.hasPermi('backend:real_auth:add')")
    @Log(title = "实名认证", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增实名认证")
    public AjaxResult add(@RequestBody SysUserRealAuth sysUserRealAuth)
    {
        return toAjax(sysUserRealAuthService.insertSysUserRealAuth(sysUserRealAuth));
    }

    /**
     * 修改实名认证
     */
    @PreAuthorize("@ss.hasPermi('backend:real_auth:edit')")
    @Log(title = "实名认证", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改实名认证")
    public AjaxResult edit(@RequestBody SysUserRealAuth sysUserRealAuth)
    {
        return toAjax(sysUserRealAuthService.updateSysUserRealAuth(sysUserRealAuth));
    }

    /**
     * 删除实名认证
     */
    @PreAuthorize("@ss.hasPermi('backend:real_auth:remove')")
    @Log(title = "实名认证", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除实名认证")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(sysUserRealAuthService.deleteSysUserRealAuthByIds(ids));
    }

    /**
     * 审核实名认证
     */
    @PreAuthorize("@ss.hasPermi('backend:real_auth:edit')")
    @Log(title = "实名认证", businessType = BusinessType.UPDATE)
    @PutMapping("/auditRealAuth")
    @ApiOperation("审核实名认证")
    public AjaxResult auditRealAuth(@RequestBody SysUserRealAuth sysUserRealAuth)
    {
        return toAjax(sysUserRealAuthService.auditRealAuth(sysUserRealAuth));
    }

    /**
     * 导出实名认证列表
     */
    /*@PreAuthorize("@ss.hasPermi('backend:real_auth:export')")
    @Log(title = "实名认证", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysUserRealAuth sysUserRealAuth)
    {
        List<SysUserRealAuth> list = sysUserRealAuthService.selectSysUserRealAuthList(sysUserRealAuth);
        ExcelUtil<SysUserRealAuth> util = new ExcelUtil<SysUserRealAuth>(SysUserRealAuth.class);
        util.exportExcel(response, list, "实名认证数据");
    }*/

}
